;;; mx.E Initialization File
;;==============================================================


(let ((minvers "25.0"))
  (when (version< emacs-version minvers)
    (error "Your Emacs is too old ! this config requires V%s or higher" minvers)))

(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))
(require 'mx-benchmarking) ;; Measure startup time

(defconst *spell-check-support-enabled* nil) ;; Enable with t if you prefer
(defconst *is-macOS* (eq system-type 'darwin))


;; Temporarily reduce garbage collection during startup
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(defconst mx/initial-gc-cons-threshold gc-cons-threshold
  "Initial value of `gc-cons-threshold' at start-up time.")
(setq gc-cons-threshold (* 256 1024 1024))
(add-hook 'after-init-hook
          (lambda () (setq gc-cons-threshold mx/initial-gc-cons-threshold)))


;; Bootstrap config
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(setq custom-file (expand-file-name "mxcus.el" user-emacs-directory))
(require 'mx-utils)
(require 'mx-site-lisp) ;; Must come before elpa, as it may provide package.el
;; Calls (package-initialize)
(require 'mx-elpa)      ;; Machinery for installing required packages
(require 'mx-exec-path) ;; Set up $PATH


;; Allow users to provide an optional "mx-prelo-private.el"
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(require 'mx-prelo-private nil t)


;; Load configs for specific features and modes
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(require-package 'wgrep)
(require-package 'project-local-variables)
(require-package 'diminish)
(require-package 'scratch)
(require-package 'command-log-mode)

;; Base Tools
;;++++++++++++++++++++++++++++++
(require 'mx-frame-hooks)
(require 'mx-xterm)
(require 'mx-themes)
(require 'mx-macOS)
(require 'mx-gui)
(require 'mx-dired)
(require 'mx-isearch)
(require 'mx-grep)
(require 'mx-uniquify)
(require 'mx-ibuffer)
(require 'mx-flycheck)
(require 'mx-recentf)
(require 'mx-smex)
(require 'mx-ivy)
(require 'mx-hippie-expand)
(require 'mx-company)
(require 'mx-windows)
(require 'mx-sessions)
(require 'mx-fonts)
(require 'mx-mmm)

;; Editing Tools
;;++++++++++++++++++++++++++++++
(require 'mx-editing-utils)
(require 'mx-whitespace)
(require 'mx-fci)

;; IME
;;++++++++++++++++++++++++++++++
(require 'mx-chinese-pyim)

;; Version Contral
;;++++++++++++++++++++++++++++++
(require 'mx-vcontral)
(require 'mx-darcs)
(require 'mx-git)
(require 'mx-github)
(require 'mx-projectile)

;; Programming Languages Support
;;++++++++++++++++++++++++++++++
(require 'mx-compile)
(require 'mx-crontab)
(require 'mx-textile)
(require 'mx-markdown)
(require 'mx-c-cpp)
(require 'mx-csv)
(require 'mx-erlang)
(require 'mx-golang)
(require 'mx-javascript)
(require 'mx-php)
(require 'mx-org)
(require 'mx-nxml)
(require 'mx-html)
(require 'mx-css)
(require 'mx-haml)
(require 'mx-python-mode)
(require 'mx-haskell)
(require 'mx-elm)
(require 'mx-ruby-mode)
(require 'mx-rails)
(require 'mx-sql)
(require 'mx-swift)
(require 'mx-paredit)
(require 'mx-lisp)
(require 'mx-slime)
(require 'mx-clojure)
(require 'mx-clojure-cider)
(require 'mx-common-lisp)

;; Spell Check Support
;;++++++++++++++++++++++++++++++
(when *spell-check-support-enabled*
  (require 'mx-spelling))

;; MISC
;;++++++++++++++++++++++++++++++
(require 'mx-misc)

;; Others
;;++++++++++++++++++++++++++++++
(require 'mx-folding)
(require 'mx-dash)
(require 'mx-ledger)

;; Extra packages which don't require any configuration
;;++++++++++++++++++++++++++++++
(require-package 'gnuplot)
(require-package 'lua-mode)
(require-package 'htmlize)
(require-package 'dsvn)
(require-package 'sudo-edit)
(when *is-macOS*
  (require-package 'osx-location))
(maybe-require-package 'regex-tool)


;; Allow access from emacsclient
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(require 'server)
(unless (server-running-p)
  (server-start))


;; Variables configured via the interactive 'customize' interface
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(when (file-exists-p custom-file)
  (load custom-file))


;; Allow users to provide an optional "mx-private.el" containing personal settings
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(require 'mx-private nil t)


;; Locales (setting them earlier in this file doesn't work in X)
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(require 'mx-locales)


;; Uptimes Support
;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(when (maybe-require-package 'uptimes)
  (add-hook 'after-init-hook (lambda () (require 'uptimes))))


(provide 'init)

;; Local Variables:
;; no-byte-compile: t
;; End:
